﻿#include "export.h"
#include "adapter_event.h"

Adapter_EventCallbackFunc gpEventCallbackFunc;
Adapter_EventParameterStruct gEventParameterStruct;

void Adapter_SetEventCallbackFunc(Adapter_EventCallbackFunc pCallbackFunc) {
    gpEventCallbackFunc = pCallbackFunc;
}

int Adapter_Event() {
    return gpEventCallbackFunc(&gEventParameterStruct);
}

void Menu() {
    gEventParameterStruct.eventType = Adapter_EventTypeMenu;
    Adapter_Event();
}

int LoadingInfo(int session) {
    gEventParameterStruct.eventType = Adapter_EventTypePluginLoad;
    gEventParameterStruct.session = session;
    return Adapter_Event();
}

int EventInit(char* path) {
    gEventParameterStruct.eventType = Adapter_EventTypeInit;
    gEventParameterStruct.pluginPath = path;
    return Adapter_Event();
}

int EventEnable() {
    gEventParameterStruct.eventType = Adapter_EventTypeEnable;
    return Adapter_Event();
}

int EventStop(int type) {
    gEventParameterStruct.eventType = Adapter_EventTypeStop;
    gEventParameterStruct.messageType = type;
    return Adapter_Event();
}

int EventLogin(LPCSTR robotWxid, LPCSTR robotName, int type, LPCSTR msg) {
    gEventParameterStruct.eventType = Adapter_EventTypeLogin;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.robotName = robotName;
    gEventParameterStruct.messageType = type;
    gEventParameterStruct.msg = msg;
    return Adapter_Event();
}

int EventGroupMsg(LPCSTR robotWxid, int type, LPCSTR fromWxid, LPCSTR fromName, LPCSTR finalFromWxid, LPCSTR finalFromName, LPCSTR toWxid, LPCSTR msg) {
    gEventParameterStruct.eventType = Adapter_EventTypeGroupMsg;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.messageType = type;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.finalFromWxid = finalFromWxid;
    gEventParameterStruct.finalFromName = finalFromName;
    gEventParameterStruct.toWxid = toWxid;
    gEventParameterStruct.msg = msg;
    return Adapter_Event();
}

int EventFriendMsg(LPCSTR robotWxid, int type, LPCSTR fromWxid, LPCSTR fromName, LPCSTR toWxid, LPCSTR msg) {
    gEventParameterStruct.eventType = Adapter_EventTypeFriendMsg;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.messageType = type;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.toWxid = toWxid;
    gEventParameterStruct.msg = msg;
    return Adapter_Event();
}

int EventReceivedTransfer(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR toWxid, LPCSTR money, LPCSTR jsonMsg) {
    gEventParameterStruct.eventType = Adapter_EventTypeReceivedTransfer;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.toWxid = toWxid;
    gEventParameterStruct.money = money;
    gEventParameterStruct.jsonMsg = jsonMsg;
    return Adapter_Event();
}

int EventScanCashMoney(LPCSTR robotWxid, LPCSTR payWxid, LPCSTR payName, LPCSTR money, LPCSTR jsonMsg) {
    gEventParameterStruct.eventType = Adapter_EventTypeScanCashMoney;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.payWxid = payWxid;
    gEventParameterStruct.payName = payName;
    gEventParameterStruct.money = money;
    gEventParameterStruct.jsonMsg = jsonMsg;
    return Adapter_Event();
}

int EventFriendVerify(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR toWxid, LPCSTR jsonMsg) {
    gEventParameterStruct.eventType = Adapter_EventTypeFriendVerify;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.toWxid = toWxid;
    gEventParameterStruct.jsonMsg = jsonMsg;
    return Adapter_Event();
}

int EventContactsChange(LPCSTR robotWxid, int type, LPCSTR fromWxid, LPCSTR fromName, LPCSTR msg) {
    gEventParameterStruct.eventType = Adapter_EventTypeContactsChange;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.messageType = type;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.msg = msg;
    return Adapter_Event();
}

int EventGroupMemberAdd(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR jsonMsg) {
    gEventParameterStruct.eventType = Adapter_EventTypeGroupMemberAdd;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.jsonMsg = jsonMsg;
    return Adapter_Event();
}

int EventGroupMemberDecrease(LPCSTR robotWxid, LPCSTR fromWxid, LPCSTR fromName, LPCSTR jsonMsg) {
    gEventParameterStruct.eventType = Adapter_EventTypeGroupMemberDecrease;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.fromWxid = fromWxid;
    gEventParameterStruct.fromName = fromName;
    gEventParameterStruct.jsonMsg = jsonMsg;
    return Adapter_Event();
}

int EventSysMsg(LPCSTR robotWxid, int type, LPCSTR jsonMsg) {
    gEventParameterStruct.eventType = Adapter_EventTypeSysMsg;
    gEventParameterStruct.robotWxid = robotWxid;
    gEventParameterStruct.messageType = type;
    gEventParameterStruct.jsonMsg = jsonMsg;
    return Adapter_Event();
}
